package com.java.learning.cha1;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class WriterDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        FileWriter fw = null;
        try {
            fw = new FileWriter("D:\\mytest2.txt");
            System.out.println("请输入内容：");
            String str = scanner.nextLine();
            fw.write(str);
            System.out.println("已保存");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
